package com.cq.hd.member.api;

import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.member.api.dto.*;
import com.cq.hd.member.api.vo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@FeignClient(value = "hd-o2o-member-service", contextId = "business-agent-api")
public interface TbBusinessAgentApi {

    // 分页列表
    @GetMapping("/member/agent/pageAgent")
    Result<Page<AgentPageVo>> pageAgent(@SpringQueryMap AgentPageDto agentPageDto);

    // 根据商家id批量获取商家经纪人关联数据
    @GetMapping("/member/agent/listByBusinessIds")
    Result<List<BusinessAgentVo>> listByBusinessIds(@RequestParam("businessIds") List<Long> businessIds);

    // 批量获取商家跟指定经纪人的佣金比例
    @GetMapping("/member/agent/getAgentCommissionRateByBusinessIds")
    Result<Map<Long, BigDecimal>> getAgentCommissionRateByBusinessIds(@RequestParam("userId") Long userId, @RequestParam("businessIds") List<Long> businessIds);

    // 获取一级经纪人给二级经纪人的佣金比例
    @GetMapping("/member/agent/getSubAgentCommissionRate")
    Result<BigDecimal> getSubAgentCommissionRate(@RequestParam("userId") Long userId, @RequestParam("agentId") Long agentId);

    // 获取商家给一级经纪人的佣金比例
    @GetMapping("/member/agent/getAgentCommissionRate")
    Result<BigDecimal> getAgentCommissionRate(@RequestParam("userId") Long userId, @RequestParam("businessId") Long businessId);

    // 经纪人绑定商家
//    @PostMapping("/member/agent/bind")
//    Result<Boolean> bind(@RequestBody BusinessAgentBindDto businessAgentBindDto);

    // 商家解除绑定经纪人分销关系
    @PostMapping("/member/agent/unBind")
    Result<Boolean> unBind(@RequestBody BusinessAgentUnBindDto businessAgentUnBindDto);

    // 角色管理主页，返回我的经纪人总数和我的策划人总数，以及是否显示经纪人/策划人总数
    @GetMapping("/member/agent/businessAgentIndex")
    Result<BusinessAgentIndexVo> businessAgentIndex(@SpringQueryMap BusinessAgentIndexDto businessAgentIndexDto);

    // 我的经纪人分页条件列表
    @GetMapping("/member/agent/pageMyAgent")
    Result<Page<MyAgentPageVo>> pageMyAgent(@SpringQueryMap MyAgentPageDto myAgentPageDto);

    // 我的策划人分页条件列表
    @GetMapping("/member/agent/pageMyBusiness")
    Result<Page<MyBusinessPageVo>> pageMyBusiness(@SpringQueryMap MyBusinessPageDto myBusinessPageDto);

    // 经纪人专属佣金设置
    @PutMapping("/member/agent/saveAgentCommission")
    Result<Boolean> saveAgentCommission(@RequestBody BusinessAgentCommissionSaveDto businessAgentCommissionSaveDto);

    // 已设置佣金和未设置佣金经纪人列表
    @GetMapping("/member/agent/pageAgentCommission")
    Result<Page<BusinessAgentCommissionPageVo>> pageAgentCommission(@SpringQueryMap BusinessAgentCommissionPageDto businessAgentCommissionPageDto);

    //	分组成员搜索
    @GetMapping("/member/agent/pageBusinessGroupAgent")
    Result<Page<BusinessGroupAgentPageVo>> pageBusinessGroupAgent(@SpringQueryMap BusinessGroupAgentPageDto businessGroupAgentPageDto);

    //	删除分组成员              需要更新分组的成员个数
    @DeleteMapping("/member/agent/deleteBusinessGroupAgent")
    Result<Boolean> deleteBusinessGroupAgent(@RequestParam("id") Long id, @RequestParam("businessId") Long businessId, @RequestParam("agentId") Long agentId);

    // 根据商家id和经纪人id查找对应的关联数据
    @GetMapping("/member/agent/getBusinessAgentById")
    Result<BusinessAgentVo> getBusinessAgentById(@RequestParam("businessId") Long businessId, @RequestParam("userId") Long userId);

    // 选择团长列表（供创建活动时设置分销佣金调用）
    @GetMapping("/member/agent/listBusinessSelectAgent")
    Result<List<BusinessSelectAgentGroupVo>> listBusinessSelectAgent(@RequestParam("userId") Long userId, @RequestParam("businessId") Long businessId);

    // 根据条件查询经纪人数据
    @GetMapping("/member/agent/listByDto")
    Result<List<BusinessAgentVo>> listByDto(@SpringQueryMap BusinessAgentDto businessAgentDto);

    // 根据日期查询新入驻的经纪人数
    @GetMapping("/member/agent/getNewCountByDate")
    Result<Integer> getNewCountByDate(@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime);

    // 更新商家与经纪人相关的统计字段
    @PostMapping("/member/agent/updateBusinessAgentOrder")
    Result<Boolean> updateBusinessAgentOrder(@RequestBody UpdateBusinessAgentOrderDto updateBusinessAgentOrderDto);

    // 更新一级经纪人与二级经纪人相关的统计字段
    @PostMapping("/member/agent/updateSubAgentOrder")
    Result<Boolean> updateSubAgentOrder(@RequestBody UpdateSubAgentOrderDto updateSubAgentOrderDto);

    // 批量删除分组成员，批量移动分组成员
    @PostMapping("/member/agent/batchChangeGroup")
    Result<Boolean> batchChangeGroup(@RequestBody BusinessGroupBatchChangeGroupDto businessGroupBatchChangeGroupDto);

    // 我的上级经纪人
    @GetMapping("/member/agent/myParentAgent")
    Result<MyAgentVo> myParentAgent(@RequestParam("userId") Long userId);

    // 我的策划人id集合
    @GetMapping("/member/agent/myBusinessIds")
    Result<List<Long>> myBusinessIds(@RequestParam("userId") Long userId);
}
